.class public Lcom/htc/android/footprints/utils/GpsFixStatus;
.super Ljava/lang/Object;
.source "GpsFixStatus.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;
    }
.end annotation


# static fields
.field private static final EXTRA_ENABLED:Ljava/lang/String; = "enabled"

.field private static final GPS_ENABLED_CHANGE_ACTION:Ljava/lang/String; = "android.location.GPS_ENABLED_CHANGE"

.field private static final GPS_FIX_CHANGE_ACTION:Ljava/lang/String; = "android.location.GPS_FIX_CHANGE"

.field private static final TAG:Ljava/lang/String; = "GpsFixStatus"

.field private static mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;


# instance fields
.field private isFix:Z

.field private mContext:Landroid/content/Context;

.field private mGpsReceiver:Landroid/content/BroadcastReceiver;

.field private mListener:Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 12
    const/4 v0, 0x0

    sput-object v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;

    return-void
.end method

.method private constructor <init>()V
    .locals 2

    .prologue
    const/4 v1, 0x0

    .line 33
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 14
    iput-object v1, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mContext:Landroid/content/Context;

    .line 16
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->isFix:Z

    .line 18
    iput-object v1, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mListener:Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;

    .line 84
    new-instance v0, Lcom/htc/android/footprints/utils/GpsFixStatus$1;

    invoke-direct {v0, p0}, Lcom/htc/android/footprints/utils/GpsFixStatus$1;-><init>(Lcom/htc/android/footprints/utils/GpsFixStatus;)V

    iput-object v0, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mGpsReceiver:Landroid/content/BroadcastReceiver;

    .line 33
    return-void
.end method

.method static synthetic access$000(Lcom/htc/android/footprints/utils/GpsFixStatus;Landroid/content/Intent;)V
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 9
    invoke-direct {p0, p1}, Lcom/htc/android/footprints/utils/GpsFixStatus;->updateGps(Landroid/content/Intent;)V

    return-void
.end method

.method public static getInstance(Landroid/content/Context;)Lcom/htc/android/footprints/utils/GpsFixStatus;
    .locals 1
    .parameter "context"

    .prologue
    .line 36
    sget-object v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;

    if-nez v0, :cond_0

    .line 37
    new-instance v0, Lcom/htc/android/footprints/utils/GpsFixStatus;

    invoke-direct {v0}, Lcom/htc/android/footprints/utils/GpsFixStatus;-><init>()V

    sput-object v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;

    .line 38
    sget-object v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;

    iput-object p0, v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mContext:Landroid/content/Context;

    .line 39
    sget-object v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;

    invoke-direct {v0}, Lcom/htc/android/footprints/utils/GpsFixStatus;->registerGpsReciver()V

    .line 41
    :cond_0
    sget-object v0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mInstance:Lcom/htc/android/footprints/utils/GpsFixStatus;

    return-object v0
.end method

.method private registerGpsReciver()V
    .locals 3

    .prologue
    .line 78
    new-instance v0, Landroid/content/IntentFilter;

    invoke-direct {v0}, Landroid/content/IntentFilter;-><init>()V

    .line 79
    .local v0, filter:Landroid/content/IntentFilter;
    const-string v1, "android.location.GPS_FIX_CHANGE"

    invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 80
    const-string v1, "android.location.GPS_ENABLED_CHANGE"

    invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 81
    iget-object v1, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mContext:Landroid/content/Context;

    iget-object v2, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mGpsReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v1, v2, v0}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 82
    return-void
.end method

.method private final updateGps(Landroid/content/Intent;)V
    .locals 5
    .parameter "intent"

    .prologue
    const/4 v4, 0x0

    const-string v3, "GpsFixStatus"

    .line 57
    invoke-virtual {p1}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v0

    .line 58
    .local v0, action:Ljava/lang/String;
    const-string v2, "enabled"

    invoke-virtual {p1, v2, v4}, Landroid/content/Intent;->getBooleanExtra(Ljava/lang/String;Z)Z

    move-result v1

    .line 60
    .local v1, enabled:Z
    const-string v2, "android.location.GPS_FIX_CHANGE"

    invoke-virtual {v0, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_1

    if-eqz v1, :cond_1

    .line 62
    const/4 v2, 0x1

    iput-boolean v2, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->isFix:Z

    .line 63
    iget-object v2, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mListener:Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;

    if-eqz v2, :cond_0

    .line 64
    iget-object v2, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mListener:Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;

    invoke-interface {v2}, Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;->onFix()V

    .line 66
    :cond_0
    const-string v2, "GpsFixStatus"

    const-string v2, "GPS_FIX_CHANGE_ACTION"

    invoke-static {v3, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 75
    :goto_0
    return-void

    .line 67
    :cond_1
    const-string v2, "android.location.GPS_ENABLED_CHANGE"

    invoke-virtual {v0, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2

    if-nez v1, :cond_2

    .line 69
    iput-boolean v4, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->isFix:Z

    .line 70
    const-string v2, "GpsFixStatus"

    const-string v2, "GPS_ENABLED_CHANGE_ACTION_OFF"

    invoke-static {v3, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0

    .line 73
    :cond_2
    const-string v2, "GpsFixStatus"

    const-string v2, "GPS_ENABLED_CHANGE_ACTION_ON"

    invoke-static {v3, v2}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0
.end method


# virtual methods
.method public isGpsFix()Z
    .locals 1

    .prologue
    .line 49
    iget-boolean v0, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->isFix:Z

    return v0
.end method

.method public removeGpsReciver()V
    .locals 2

    .prologue
    .line 45
    iget-object v0, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mContext:Landroid/content/Context;

    iget-object v1, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mGpsReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v0, v1}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 46
    return-void
.end method

.method public setFixListener(Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;)V
    .locals 0
    .parameter "listener"

    .prologue
    .line 53
    iput-object p1, p0, Lcom/htc/android/footprints/utils/GpsFixStatus;->mListener:Lcom/htc/android/footprints/utils/GpsFixStatus$FixListener;

    .line 54
    return-void
.end method
